package main

import (
	"fmt"
	"os"
	"path/filepath"
	"runtime/trace"
)

// go tool trace trace.out
func main() {
	//创建trace文件

	getwd, err := os.Getwd()
	if err != nil {
		return
	}
	fmt.Println(getwd)
	f, err := os.OpenFile(filepath.Join(getwd, "/syncx/goroutinex/cmd/trace.out"), os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0644)
	if err != nil {
		panic(err)
	}
	defer f.Close()

	//启动trace goroutine
	err = trace.Start(f)
	if err != nil {
		panic(err)
	}
	defer trace.Stop()

	//main_test.go
	fmt.Println("Hello World")
}
